// 定义核心业务Table Columns
import * as constants from 'src/AppConstants'
import utils from 'commons/utils'
import {StatusColumn, StatusFixedColumn} from './base_columns'

export const RegistUserColumns = [{
        title: '用户名',
        key: 'username',
        width: 120,
        fixed: 'left',
        sortable: true
    },
    {
        title: '昵称',
        key: 'nickname',
        width: 100
    },
    {
        title: '手机',
        key: 'phone',
        width: 160,
        align: 'center'
    },
    {
        title: '渠道',
        key: 'channel',
        width: 100,
        render(row, column, index) {
            return utils.getNameByCode(constants.CHANNELS, row.channel)
        }
    },
    {
        title: '性别',
        key: 'sex',
        align: 'center',
        width: 80,
        render(row, column, index) {
            return utils.getNameByCode(constants.SEX, row.sex)
        }
    },
    {
        title: '年龄',
        width: 80,
        sortable: true,
        key: 'age'
    },
    {
        title: '所在城市',
        key: 'city',
        width: 200,
        render(row, column, index) {
            return [row.province||'', row.city||''].join('')
        }
    },
    {
        title: '公司',
        key: 'company',
        width: 160
    },
    {
        title: '工作',
        key: 'job',
        width: 120
    },
    {
        title: '最后登录时间',
        key: 'lastLoginTime',
        sortable: true,
        align: 'center',
        width: 160
    },
    {
        title: '最后登录IP',
        key: 'lastLoginIP',
        align: 'center',
        width: 160
    },
    StatusFixedColumn,
    {
        title: '操作',
        key: 'action',
        align: 'center',
        width: 240,
        fixed: 'right',
        render (row, column, index) {
            return `<i-button type="text" size="small" icon="edit" @click="onEdit(${index})">编辑</i-button>
                     <i-button type="text" size="small" icon="key" @click="onEditPwd(${index})">修改密码</i-button>`
        }
    }
]
